from django.db import models


class Personnel(models.Model):
    """
    人员信息模型
    对应前端InfoMaintenance组件的数据结构
    """
    name = models.CharField(max_length=100, verbose_name='姓名')
    phone = models.CharField(max_length=20, blank=True, null=True, verbose_name='电话')
    group = models.CharField(max_length=50, verbose_name='分组')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        verbose_name = '人员信息'
        verbose_name_plural = '人员信息'
        ordering = ['id']

    def __str__(self):
        return f"{self.name} ({self.group})"


class Equipment(models.Model):
    """
    设备维护模型
    对应前端InfoMaintenance组件中设备维护选项卡的数据结构
    """
    name = models.CharField(max_length=200, verbose_name='试验设备名称')
    experiment = models.CharField(max_length=200, verbose_name='相关试验')
    responsible = models.CharField(max_length=100, verbose_name='设备负责人')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        verbose_name = '设备信息'
        verbose_name_plural = '设备信息'
        ordering = ['id']

    def __str__(self):
        return f"{self.name} - {self.responsible}"
